<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .demo {
            width: 100px;
            height: 100px;
            background-color: yellow;
            cursor: pointer;
            position: absolute;
            left: 100px;
        }
    </style>
</head>

<body>
这是我在桌面修改的代码
    <div class="demo"></div>
    <script>
        var demo = document.querySelector(".demo")
        document.onclick = e => {
            var x = demo.offsetLeft - e.clientX
            var y = demo.offsetTop - e.clientY

            demo.onmousemove = e => {

            }
            document.onmouseup = e => {
                demo.style.top = e.clientX + x + "px"
                demo.style.left = e.clientY + y + "px"
                console.log(demo.style.left)
            }
        }
    </script>

</body>

</html>